package com.itheima.service.imp;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.NursingLevelMapper;
import com.itheima.mapper.NursingPlanMapper;
import com.itheima.pojo.*;
import com.itheima.service.NursingLevelService;
import com.itheima.service.NursingPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class NursingPlanServiceImpl implements NursingPlanService {


    @Autowired
    private NursingPlanMapper nursingPlanMapper;


    @Override
    public PageResultwo listwo(NursingPlanQueryParam nursingPlanQueryParam) {
        //1、分页设置
        PageHelper.startPage(nursingPlanQueryParam.getPage(),nursingPlanQueryParam.getPageSize());

        //3、执行查询
        List<NursingPlan> listwo = nursingPlanMapper.listwo(nursingPlanQueryParam);
        Page<NursingPlan> pageList = (Page<NursingPlan>) listwo;

        //4、封装PageResult对象
        return new PageResultwo(pageList.getTotal(),pageList.getResult());

    }

    @Override
    public Integer add(NursingPlan nursingPlan) {
        return nursingPlanMapper.add(nursingPlan);
    }
}